<html>
<header>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="../css/style.css">
<link rel="stylesheet" type="text/css" href="../css/jquery.treeview.css">
<style type="text/css">
<!--
textarea {width:100%;height:90px;overflow:auto}
-->
</style>
<script type="text/javascript">//<![CDATA[
var VIEW_URL = '/djambe/view/';
var IFRAME_VIEW_URL = '/djambe/iframe_view/';
var MEDIA_URL = '/djambe_media/media/';
var IFRAME_ID = 0;

function el(id) {
  return document.getElementById(id);
}

function test_all() {
  var pass_count = 0;
  var fail_count = 0;
  var i = 1;

  while(1) {
    if(i < 10) {
      test_id = '00' + i;
    }
    else if(i < 100) {
      test_id = '0' + i;
    }
    else {
      test_id = i;
    }

    if(!el('test' + test_id)) break;

    el('dest' + test_id).value = wikify(el('src' + test_id).value);
    if(el('view' + test_id)) {
      el('view' + test_id).innerHTML = el('expected' + test_id).value;
    }
    if(el('dest' + test_id).value == el('expected' + test_id).value) {
      el('result' + test_id).innerHTML = '<span style="color:blue">Pass</span>';
      pass_count++;
    }
    else {
      el('result' + test_id).innerHTML = '<span style="color:red">Fail</span>';
      fail_count++;
    }
    i++;
  }

  $('.treeview').treeview();
  el('pass_count').innerHTML = pass_count;
  el('fail_count').innerHTML = fail_count;
}
//]]>
</script>
<script language="JavaScript" src="jquery.min.js"></script>
<script language="JavaScript" src="render.js"></script>
</header>
<body onLoad="test_all()">
<span style="color:blue">Pass:<span id="pass_count"></span></span></br>
<span style="color:red">Fail:<span id="fail_count"></span></span>

<div id="test001">
<h1>test001: Plain text</h1>
<h3>Source:</h3>
<textarea id="src001">aaa
bbb

ccc
</textarea>
<h3>Expected:</h3>
<textarea id="expected001">aaa<br />
bbb<br />
<br />
ccc</textarea>
<h3>Returned Value:</h3>
<textarea id="dest001"></textarea>
<h3>HTML View:</h3>
<div id="view001"></div>
<h3>Result:<span id="result001"></span></h3>
</div>

<div id="test002">
<h1>test002: Mixture of link and strike</h1>
<h3>Source:</h3>
<textarea id="src002">==[[Google|http://www.google.com/]]==</textarea>
<h3>Expected:</h3>
<textarea id="expected002"><span style="text-decoration:line-through"><a href="http://www.google.com/" target="_blank">Google</a></span></textarea>
<h3>Returned Value:</h3>
<textarea id="dest002"></textarea>
<h3>HTML View:</h3>
<div id="view002"></div>
<h3>Result:<span id="result002"></span></h3>
</div>

<div id="test003">
<h1>test003: Escape wikify</h1>
<h3>Source:</h3>
<textarea id="src003">{{{[[Google|http://www.google.com/]]}}}</textarea>
<h3>Expected:</h3>
<textarea id="expected003">[[Google|http://www.google.com/]]</textarea>
<h3>Returned Value:</h3>
<textarea id="dest003"></textarea>
<h3>HTML View:</h3>
<div id="view003"></div>
<h3>Result:<span id="result003"></span></h3>
</div>

<div id="test004">
<h1>test004: Escape wikify</h1>
<h3>Source:</h3>
<textarea id="src004">Escape this.
{{{*H1
----
-List}}}
End of escape1.
{{{**H2
+List}}}
End of escape2.</textarea>
<h3>Expected:</h3>
<textarea id="expected004">Escape this.
*H1
----
-List<br />
End of escape1.
**H2
+List<br />
End of escape2.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest004"></textarea>
<h3>HTML View:</h3>
<div id="view004"></div>
<h3>Result:<span id="result004"></span></h3>
</div>

<div id="test005">
<h1>test005: H1 - H6</h1>
<h3>Source:</h3>
<textarea id="src005">*H1
text1
**H2
text2
***H3
text3
****H4
text4
*****H5
text5
******H6
text6
</textarea>
<h3>Expected:</h3>
<textarea id="expected005"><h1>H1</h1>
text1
<h2>H2</h2>
text2
<h3>H3</h3>
text3
<h4>H4</h4>
text4
<h5>H5</h5>
text5
<h6>H6</h6>
text6</textarea>
<h3>Returned Value:</h3>
<textarea id="dest005"></textarea>
<h3>HTML View:</h3>
<div id="view005"></div>
<h3>Result:<span id="result005"></span></h3>
</div>

<div id="test006">
<h1>test006: UL</h1>
<h3>Source:</h3>
<textarea id="src006">This is a list.
-Item A
-Item B
--Item B-a
---Item B-a-x
---Item B-a-y
-Item C
End of list.
</textarea>
<h3>Expected:</h3>
<textarea id="expected006">This is a list.
<ul>
<li>Item A</li>
<li>Item B
<ul>
<li>Item B-a
<ul>
<li>Item B-a-x</li>
<li>Item B-a-y</li>
</ul></li>
</ul></li>
<li>Item C</li>
</ul>
End of list.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest006"></textarea>
<h3>HTML View:</h3>
<div id="view006"></div>
<h3>Result:<span id="result006"></span></h3>

<div id="test007">
<h1>test007: OL</h1>
<h3>Source:</h3>
<textarea id="src007">This is a list.
#Item 1
##Item 1-1
###Item 1-1-1
#Item 2
#Item 3
End of list.
</textarea>
<h3>Expected:</h3>
<textarea id="expected007">This is a list.
<ol>
<li>Item 1
<ol>
<li>Item 1-1
<ol>
<li>Item 1-1-1</li>
</ol></li>
</ol></li>
<li>Item 2</li>
<li>Item 3</li>
</ol>
End of list.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest007"></textarea>
<h3>HTML View:</h3>
<div id="view007"></div>
<h3>Result:<span id="result007"></span></h3>

<div id="test008">
<h1>test008: Strike</h1>
<h3>Source:</h3>
<textarea id="src008">This ==word== is deleted.</textarea>
<h3>Expected:</h3>
<textarea id="expected008">This <span style="text-decoration:line-through">word</span> is deleted.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest008"></textarea>
<h3>HTML View:</h3>
<div id="view008"></div>
<h3>Result:<span id="result008"></span></h3>
</div>

<div id="test009">
<h1>test009: Bold</h1>
<h3>Source:</h3>
<textarea id="src009">This ''word'' is bold.</textarea>
<h3>Expected:</h3>
<textarea id="expected009">This <span style="font-weight:bold">word</span> is bold.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest009"></textarea>
<h3>HTML View:</h3>
<div id="view009"></div>
<h3>Result:<span id="result009"></span></h3>
</div>

<div id="test010">
<h1>test010: Italic</h1>
<h3>Source:</h3>
<textarea id="src010">This %%word%% is italic.</textarea>
<h3>Expected:</h3>
<textarea id="expected010">This <span style="font-style:italic">word</span> is italic.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest010"></textarea>
<h3>HTML View:</h3>
<div id="view010"></div>
<h3>Result:<span id="result010"></span></h3>
</div>

<div id="test011">
<h1>test011: Underline</h1>
<h3>Source:</h3>
<textarea id="src011">This __word__ is underlined.</textarea>
<h3>Expected:</h3>
<textarea id="expected011">This <span style="text-decoration:underline">word</span> is underlined.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest011"></textarea>
<h3>HTML View:</h3>
<div id="view011"></div>
<h3>Result:<span id="result011"></span></h3>
</div>

<div id="test012">
<h1>test012: BlockQuote</h1>
<h3>Source:</h3>
<textarea id="src012">He said
>I say this.
End of quote.</textarea>
<h3>Expected:</h3>
<textarea id="expected012">He said
<blockquote class="wiki">
<p class="wiki">
I say this.
</p>
</blockquote>
End of quote.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest012"></textarea>
<h3>HTML View:</h3>
<div id="view012"></div>
<h3>Result:<span id="result012"></span></h3>
</div>

<div id="test013">
<h1>test013: Nested BlockQuote 1</h1>
<h3>Source:</h3>
<textarea id="src013">He said
>I hear she says
>>I say this
>>and that.
>to me.
End of quote.</textarea>
<h3>Expected:</h3>
<textarea id="expected013">He said
<blockquote class="wiki">
<p class="wiki">
I hear she says
</p>
<blockquote class="wiki">
<p class="wiki">
I say this
<br />and that.
</p>
</blockquote>
<p class="wiki">
to me.
</p>
</blockquote>
End of quote.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest013"></textarea>
<h3>HTML View:</h3>
<div id="view013"></div>
<h3>Result:<span id="result013"></span></h3>
</div>

<div id="test014">
<h1>test014: Nested BlockQuote 2</h1>
<h3>Source:</h3>
<textarea id="src014">He said
>>I say this
>>and that.
>she said.
End of quote.</textarea>
<h3>Expected:</h3>
<textarea id="expected014">He said
<blockquote class="wiki">
<blockquote class="wiki">
<p class="wiki">
I say this
<br />and that.
</p>
</blockquote>
<p class="wiki">
she said.
</p>
</blockquote>
End of quote.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest014"></textarea>
<h3>HTML View:</h3>
<div id="view014"></div>
<h3>Result:<span id="result014"></span></h3>
</div>

<div id="test015">
<h1>test015: Nested BlockQuote 3</h1>
<h3>Source:</h3>
<textarea id="src015">He said
>I hear she says
>>I say this
>>and that.
End of quote.</textarea>
<h3>Expected:</h3>
<textarea id="expected015">He said
<blockquote class="wiki">
<p class="wiki">
I hear she says
</p>
<blockquote class="wiki">
<p class="wiki">
I say this
<br />and that.
</p>
</blockquote>
</blockquote>
End of quote.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest015"></textarea>
<h3>HTML View:</h3>
<div id="view015"></div>
<h3>Result:<span id="result015"></span></h3>
</div>

<div id="test016">
<h1>test016: Code Block</h1>
<h3>Source:</h3>
<textarea id="src016">Here is a code.
 var VIEW_URL, IFRAME_VIEW_URL;
 var IFRAME_ID = 0;
 
 function render() {
   VIEW_URL = document.getElementById('root_url').innerHTML + 'view/';
   IFRAME_VIEW_URL = document.getElementById('root_url').innerHTML + 'iframe_view/';
   document.getElementById('page_body').innerHTML = wikify(document.getElementById('page_text').value);
   if(document.getElementById('iframe_id')) {
     var h = document.body.scrollHeight + 31;
     parent.document.getElementById(document.getElementById('iframe_id').innerHTML).style.height = h + 'px';
   }
 }
End of code.</textarea>
<h3>Expected:</h3>
<textarea id="expected016">Here is a code.
<pre class="code">
var VIEW_URL, IFRAME_VIEW_URL;
var IFRAME_ID = 0;

function render() {
  VIEW_URL = document.getElementById('root_url').innerHTML + 'view/';
  IFRAME_VIEW_URL = document.getElementById('root_url').innerHTML + 'iframe_view/';
  document.getElementById('page_body').innerHTML = wikify(document.getElementById('page_text').value);
  if(document.getElementById('iframe_id')) {
    var h = document.body.scrollHeight + 31;
    parent.document.getElementById(document.getElementById('iframe_id').innerHTML).style.height = h + 'px';
  }
}
</pre>
End of code.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest016"></textarea>
<h3>HTML View:</h3>
<div id="view016"></div>
<h3>Result:<span id="result016"></span></h3>
</div>

<div id="test017">
<h1>test017: Line Break</h1>
<h3>Source:</h3>
<textarea id="src017">Line\nBreak</textarea>
<h3>Expected:</h3>
<textarea id="expected017">Line<br />Break</textarea>
<h3>Returned Value:</h3>
<textarea id="dest017"></textarea>
<h3>HTML View:</h3>
<div id="view017"></div>
<h3>Result:<span id="result017"></span></h3>
</div>

<div id="test018">
<h1>test018: \ Escape</h1>
<h3>Source:</h3>
<textarea id="src018">Line\\nBreak</textarea>
<h3>Expected:</h3>
<textarea id="expected018">Line\nBreak</textarea>
<h3>Returned Value:</h3>
<textarea id="dest018"></textarea>
<h3>HTML View:</h3>
<div id="view018"></div>
<h3>Result:<span id="result018"></span></h3>
</div>

<div id="test019">
<h1>test019: Bold Strike Mix</h1>
<h3>Source:</h3>
<textarea id="src019">Here are ''bold'' and ==strike==.</textarea>
<h3>Expected:</h3>
<textarea id="expected019">Here are <span style="font-weight:bold">bold</span> and <span style="text-decoration:line-through">strike</span>.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest019"></textarea>
<h3>HTML View:</h3>
<div id="view019"></div>
<h3>Result:<span id="result019"></span></h3>
</div>

<div id="test020">
<h1>test020: Strike Bold Mix</h1>
<h3>Source:</h3>
<textarea id="src020">Here are ==strike== and ''bold''.</textarea>
<h3>Expected:</h3>
<textarea id="expected020">Here are <span style="text-decoration:line-through">strike</span> and <span style="font-weight:bold">bold</span>.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest020"></textarea>
<h3>HTML View:</h3>
<div id="view020"></div>
<h3>Result:<span id="result020"></span></h3>
</div>

<div id="test021">
<h1>test021: Sanitize</h1>
<h3>Source:</h3>
<textarea id="src021">HTML tag is start with < and end with >.</textarea>
<h3>Expected:</h3>
<textarea id="expected021">HTML tag is start with &lt; and end with &gt;.</textarea>
<h3>Returned Value:</h3>
<textarea id="dest021"></textarea>
<h3>HTML View:</h3>
<div id="view021"></div>
<h3>Result:<span id="result021"></span></h3>
</div>

<div id="test022">
<h1>test022: Plugin local img without a label</h1>
<h3>Source:</h3>
<textarea id="src022">before image
[img[test.jpg]]
after image</textarea>
<h3>Expected:</h3>
<textarea id="expected022">before image<br />
<img alt="test.jpg" src="/djambe_media/media/plugins/img/test.jpg" /><br />
after image</textarea>
<h3>Returned Value:</h3>
<textarea id="dest022"></textarea>
<h3>HTML View:</h3>
<div id="view022"></div>
<h3>Result:<span id="result022"></span></h3>
</div>

<div id="test023">
<h1>test023: Plugin local img with a label</h1>
<h3>Source:</h3>
<textarea id="src023">before image
[img[label|test.jpg]]
after image</textarea>
<h3>Expected:</h3>
<textarea id="expected023">before image<br />
<img alt="label" src="/djambe_media/media/plugins/img/test.jpg" /><br />
after image</textarea>
<h3>Returned Value:</h3>
<textarea id="dest023"></textarea>
<h3>HTML View:</h3>
<div id="view023"></div>
<h3>Result:<span id="result023"></span></h3>
</div>

<div id="test024">
<h1>test024: Plugin remote img without a label</h1>
<h3>Source:</h3>
<textarea id="src024">before image
[img[http://farm5.static.flickr.com/4143/4924563855_c3a004624b_s.jpg]]
after image</textarea>
<h3>Expected:</h3>
<textarea id="expected024">before image<br />
<img alt="http://farm5.static.flickr.com/4143/4924563855_c3a004624b_s.jpg" src="http://farm5.static.flickr.com/4143/4924563855_c3a004624b_s.jpg" /><br />
after image</textarea>
<h3>Returned Value:</h3>
<textarea id="dest024"></textarea>
<h3>HTML View:</h3>
<div id="view024"></div>
<h3>Result:<span id="result024"></span></h3>
</div>

<div id="test025">
<h1>test025: Plugin remote img with a label</h1>
<h3>Source:</h3>
<textarea id="src025">before image
[img[label|http://farm5.static.flickr.com/4143/4924563855_c3a004624b_s.jpg]]
after image</textarea>
<h3>Expected:</h3>
<textarea id="expected025">before image<br />
<img alt="label" src="http://farm5.static.flickr.com/4143/4924563855_c3a004624b_s.jpg" /><br />
after image</textarea>
<h3>Returned Value:</h3>
<textarea id="dest025"></textarea>
<h3>HTML View:</h3>
<div id="view025"></div>
<h3>Result:<span id="result025"></span></h3>
</div>

<div id="test026">
<h1>test026: HR</h1>
<h3>Source:</h3>
<textarea id="src026">before HR
----
after HR</textarea>
<h3>Expected:</h3>
<textarea id="expected026">before HR
<hr />
after HR</textarea>
<h3>Returned Value:</h3>
<textarea id="dest026"></textarea>
<h3>HTML View:</h3>
<div id="view026"></div>
<h3>Result:<span id="result026"></span></h3>
</div>

<div id="test027">
<h1>test027: Treeview</h1>
<h3>Source:</h3>
<textarea id="src027">+Item A
+Item B
++Item B-a
+++Item B-a-x
+++Item B-a-y
+Item C

+Item 2A
++Item 2A-a
+++Item 2A-a-x
+++Item 2A-a-y
++Item 2A-b
+++Item 2A-b-x
+++Item 2A-b-y
+Item 2B
++Item 2B-a
+++Item 2B-a-x
+++Item 2B-a-y
+Item 2C</textarea>
<h3>Expected:</h3>
<textarea id="expected027"><ul class="treeview">
<li>Item A</li>
<li>Item B
<ul>
<li>Item B-a
<ul>
<li>Item B-a-x</li>
<li>Item B-a-y</li>
</ul></li>
</ul></li>
<li>Item C</li>
</ul>
<br />
<ul class="treeview">
<li>Item 2A
<ul>
<li>Item 2A-a
<ul>
<li>Item 2A-a-x</li>
<li>Item 2A-a-y</li>
</ul></li>
<li>Item 2A-b
<ul>
<li>Item 2A-b-x</li>
<li>Item 2A-b-y</li>
</ul></li>
</ul></li>
<li>Item 2B
<ul>
<li>Item 2B-a
<ul>
<li>Item 2B-a-x</li>
<li>Item 2B-a-y</li>
</ul></li>
</ul></li>
<li>Item 2C</li>
</ul></textarea>
<h3>Returned Value:</h3>
<textarea id="dest027"></textarea>
<h3>HTML View:</h3>
<div id="view027"></div>
<h3>Result:<span id="result027"></span></h3>
</div>

<div id="test028">
<h1>test028: Mail Address</h1>
<h3>Source:</h3>
<textarea id="src028">'xxx xxx' <xxx@aaa.co.jp>,'yyy yyy' <yyy@bbb.ne.jp>,'zzz zzz' <zzz@ccc.ne.jp></textarea>
<h3>Expected:</h3>
<textarea id="expected028">'xxx xxx' &amp;lt;xxx@aaa.co.jp&amp;gt;,'yyy yyy' &amp;lt;yyy@bbb.ne.jp&amp;gt;,'zzz zzz' &amp;lt;zzz@ccc.ne.jp&amp;gt;</textarea>
<h3>Returned Value:</h3>
<textarea id="dest028"></textarea>
<h3>HTML View:</h3>
<div id="view028"></div>
<h3>Result:<span id="result028"></span></h3>
</div>

<div id="test029">
<h1>test029: Effects in cells</h1>
<h3>Source:</h3>
<textarea id="src029">|''bold''|</textarea>
<h3>Expected:</h3>
<textarea id="expected029"><table class="wiki">
<tr class="wiki">
<td class="wiki"><span style="font-weight:bold">bold</span></td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest029"></textarea>
<h3>HTML View:</h3>
<div id="view029"></div>
<h3>Result:<span id="result029"></span></h3>
</div>

<div id="test030">
<h1>test030: Line break in cells</h1>
<h3>Source:</h3>
<textarea id="src030">|first\nsecond|</textarea>
<h3>Expected:</h3>
<textarea id="expected030"><table class="wiki">
<tr class="wiki">
<td class="wiki">first<br />second</td>
</tr>
</table></textarea>
<h3>Returned Value:</h3>
<textarea id="dest030"></textarea>
<h3>HTML View:</h3>
<div id="view030"></div>
<h3>Result:<span id="result030"></span></h3>
</div>

</body>
</html>